export default function define(Blocks: Blockly.BlockDefinitions) {

  Blocks['scrollnew'] = {
    init: function () {
      this.appendDummyInput()
        .appendField('滚动显示字符串("'); 
      this.appendValueInput("displaytext")
        .setCheck(null);
      this.appendDummyInput()
        .appendField('")');
      this.setPreviousStatement(true, null);
      this.setNextStatement(true, null);
      this.setColour("#C3E516","#C3E516","#a4b835");
      this.setTooltip('Scroll a Message');
      this.setHelpUrl('');
    },
  };

  //deprecated
  
  Blocks['scroll'] = {
    init: function () {
      this.appendDummyInput()
        .appendField('滚动显示("')
        .appendField(new Blockly.FieldTextInput('Hello World'), 'message')
        .appendField('")');
      this.setPreviousStatement(true, null);
      this.setNextStatement(true, null);
      this.setColour("#C3E516","#C3E516","#a4b835");
      this.setTooltip('Scroll a Message');
      this.setHelpUrl('');
    },
};

  Blocks['scrollvar'] = {
    init: function () {
      this.appendDummyInput()
        .appendField('滚动显示变量(')
        .appendField(new Blockly.FieldTextInput(''), 'message')
        .appendField(')');
      this.setPreviousStatement(true, null);
      this.setNextStatement(true, null);
      this.setColour("#C3E516","#C3E516","#a4b835");
      this.setTooltip('Scroll a variable');
      this.setHelpUrl('');
    },
  };

  Blocks['scrollvarnew'] = {
    init: function () {
      this.appendDummyInput()
        .appendField('滚动显示('); 
      this.appendValueInput("displaytextvar")
        .setCheck(null);
      this.appendDummyInput()
        .appendField(')');
      this.setPreviousStatement(true, null);
      this.setNextStatement(true, null);
      this.setColour("#C3E516","#C3E516","#a4b835");
      this.setTooltip('Scroll a variable');
      this.setHelpUrl('');
    },
  };
  
  Blocks['imagenew'] = {
    init: function () {
      this.appendDummyInput()
        .appendField('显示图像('); 
      this.appendValueInput("imagevar")
        .setCheck(null);
      this.appendDummyInput()
        .appendField(')');
      this.setPreviousStatement(true, null);
      this.setNextStatement(true, null);
      this.setColour("#C3E516","#C3E516","#a4b835");
      this.setTooltip('Show an image');
      this.setHelpUrl('');
    },
  };

  Blocks['image'] = {
    init: function () {
      this.appendDummyInput()
        .appendField('显示图像(')
        .appendField(new Blockly.FieldTextInput(''), 'image')
        .appendField(')');
      this.setPreviousStatement(true, null);
      this.setNextStatement(true, null);
      this.setColour("#C3E516","#C3E516","#a4b835");
      this.setTooltip('Display an image');
      this.setHelpUrl('');
    },
  };

  //deprecated

  Blocks['getpixel'] = {
    init: function () {
      this.appendDummyInput()
        .appendField('display.get_pixel(')
        .appendField(new Blockly.FieldTextInput(''), 'xy')
        .appendField(')');
      this.setPreviousStatement(true, null);
      this.setNextStatement(true, null);
      this.setColour("#C3E516","#C3E516","#a4b835");
      this.setTooltip('Gets a pixel value');
      this.setHelpUrl('');
    },
  };

  Blocks['getpixelnew'] = {
    init: function () {
      this.appendDummyInput()
        .appendField('display.get_pixel(')
        this.appendValueInput("text")
          .setCheck(null);
        this.appendDummyInput()
        .appendField(')');
      this.setPreviousStatement(true, null);
      this.setNextStatement(true, null);
      this.setColour("#C3E516","#C3E516","#a4b835");
      this.setTooltip('Gets a pixel value');
      this.setHelpUrl('');
    },
  };

  //deprecated

  Blocks['setpixel'] = {
    init: function () {
      this.appendDummyInput()
        .appendField('display.set_pixel(')
        .appendField(new Blockly.FieldTextInput(''), 'setpix')
        .appendField(')');
      this.setPreviousStatement(true, null);
      this.setNextStatement(true, null);
      this.setColour("#C3E516","#C3E516","#a4b835");
      this.setTooltip('Set a pixel');
      this.setHelpUrl('');
    },
  };

  Blocks['setpixelnew'] = {
    init: function () {
      this.appendDummyInput()
        .appendField('设置像素点(')
        this.appendValueInput("text")
          .setCheck(null);
        this.appendDummyInput()
        .appendField(')');
      this.setPreviousStatement(true, null);
      this.setNextStatement(true, null);
      this.setColour("#C3E516","#C3E516","#a4b835");
      this.setTooltip('Set a pixel');
      this.setHelpUrl('');
    },
  };


  Blocks['disclear'] = {
    init: function () {
      this.appendDummyInput()
        .appendField('清除显示');
      this.setPreviousStatement(true, null);
      this.setNextStatement(true, null);
      this.setColour("#C3E516","#C3E516","#a4b835");
      this.setTooltip('Clear the display');
      this.setHelpUrl('');
    },
  };

  Blocks['disonoff'] = {
    init: function() {
      this.appendDummyInput()
          .appendField("显示")
          .appendField(new Blockly.FieldDropdown([["打开","on"], ["关闭","off"]]), "NAME")
          .appendField("");
      this.setPreviousStatement(true, null);
      this.setNextStatement(true, null);
      this.setColour("#C3E516","#C3E516","#a4b835");
      this.setTooltip("Turn the display on/off");
      this.setHelpUrl("");
    }
  };


  Blockly.Blocks['imagecreate'] = {
    init: function() {
      this.appendDummyInput()
          .appendField(new Blockly.FieldVariable("image"), "image")
          .appendField(" = (\"")
          .appendField(new Blockly.FieldNumber(0, 9), "1")
          .appendField(new Blockly.FieldNumber(0, 9), "2")
          .appendField(new Blockly.FieldNumber(0, 9), "3")
          .appendField(new Blockly.FieldNumber(0, 9), "4")
          .appendField(new Blockly.FieldNumber(0, 9), "5")
          .appendField(":\"")
          .setAlign(Blockly.ALIGN_RIGHT);
      this.appendDummyInput()
          .appendField(new Blockly.FieldNumber(0, 9), "6")
          .appendField(new Blockly.FieldNumber(0, 9), "7")
          .appendField(new Blockly.FieldNumber(0, 9), "8")
          .appendField(new Blockly.FieldNumber(0, 9), "9")
          .appendField(new Blockly.FieldNumber(0, 9), "10")
          .appendField(":\"")
          .setAlign(Blockly.ALIGN_RIGHT);
      this.appendDummyInput()
          .appendField(new Blockly.FieldNumber(0, 9), "11")
          .appendField(new Blockly.FieldNumber(0, 9), "12")
          .appendField(new Blockly.FieldNumber(0, 9), "13")
          .appendField(new Blockly.FieldNumber(0, 9), "14")
          .appendField(new Blockly.FieldNumber(0, 9), "15")
          .appendField(":\"")
          .setAlign(Blockly.ALIGN_RIGHT);
      this.appendDummyInput()
          .appendField(new Blockly.FieldNumber(0, 9), "16")
          .appendField(new Blockly.FieldNumber(0, 9), "17")
          .appendField(new Blockly.FieldNumber(0, 9), "18")
          .appendField(new Blockly.FieldNumber(0, 9), "19")
          .appendField(new Blockly.FieldNumber(0, 9), "20")
          .appendField(":\"")
          .setAlign(Blockly.ALIGN_RIGHT);
      this.appendDummyInput()
          .appendField(new Blockly.FieldNumber(0, 9), "21")
          .appendField(new Blockly.FieldNumber(0, 9), "22")
          .appendField(new Blockly.FieldNumber(0, 9), "23")
          .appendField(new Blockly.FieldNumber(0, 9), "24")
          .appendField(new Blockly.FieldNumber(0, 9), "25")
          .appendField("\")")
          .setAlign(Blockly.ALIGN_RIGHT);
      this.setPreviousStatement(true, null);
      this.setNextStatement(true, null);
      this.setInputsInline(false);
      this.setColour("#C3E516","#C3E516","#a4b835");
      this.setTooltip("");
      this.setHelpUrl("");
    }
  };


  

var image_expressions = [
  ["心","Image.HEART"], 
  ["心(小)","Image.HEART_SMALL"], 
  ["高兴","Image.HAPPY"],
  ["微笑","Image.SMILE"], 
  ["悲伤","Image.SAD"], 
  ["困惑","Image.CONFUSED"],
  ["生气","Image.ANGRY"], 
  ["睡觉","Image.ASLEEP"],
  ["惊讶","Image.SURPRISED"], 
  ["傻乎乎的","Image.SILLY"], 
  ["Image.FABULOUS","Image.FABULOUS"],
  ["Image.MEH","Image.MEH"]
];

  var image_clocks = [
    ["时钟1","Image.CLOCK1"], 
    ["时钟2","Image.CLOCK2"], 
    ["时钟3","Image.CLOCK3"],
    ["时钟4","Image.CLOCK4"], 
    ["时钟5","Image.CLOCK5"], 
    ["时钟6","Image.CLOCK6"],
    ["时钟7","Image.CLOCK7"], 
    ["时钟8","Image.CLOCK8"],
    ["时钟9","Image.CLOCK9"], 
    ["时钟10","Image.CLOCK10"], 
    ["时钟11","Image.CLOCK11"],
    ["时钟12","Image.CLOCK12"]
  ];
  
  var image_shapes = [
      ["三角形","Image.TRIANGLE"], 
      ["左三角","Image.TRIANGLE_LEFT"], 
      ["棋盘","Image.CHESSBOARD"],
      ["钻石","Image.DIAMOND"], 
      ["钻石（小）","Image.DIAMOND_SMALL"], 
      ["正方形","Image.SQUARE"],
      ["正方形（小）","Image.SQUARE_SMALL"], 
      ["草叉","Image.PITCHFORK"],
      ["四分音符","Image.MUSIC_CROTCHET"], 
      ["八分音符","Image.MUSIC_QUAVER"], 
      ["八分音符（多）","Image.MUSIC_QUAVERS"],
      ["圣诞节","Image.XMAS"],
      ["吃豆人","Image.PACMAN"],
      ["靶子","Image.TARGET"],
      ["T恤","Image.TSHIRT"],
      ["溜冰鞋","Image.ROLLERSKATE"],
      ["房子","Image.HOUSE"],
      ["建","Image.SWORD"],
      ["雨伞","Image.UMBRELLA"]
    ];

    var image_animals = [
      ["兔子","Image.RABBIT"], 
      ["牛","Image.COW"], 
      ["鸭子","Image.DUCK"],
      ["陆龟","Image.TORTOISE"], 
      ["蝴蝶","Image.BUTTERFLY"], 
      ["火柴人","Image.STICKFIGURE"],
      ["山羊","Image.GHOST"], 
      ["长颈鹿","Image.GIRAFFE"],
      ["骷髅","Image.SKULL"], 
      ["蛇","Image.SNAKE"]
   ];

  Blocks['expressions'] = {
    init: function() {
      this.appendDummyInput()
          .appendField(new Blockly.FieldDropdown(image_expressions), "image");
      this.setOutput(true, "String");
      this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
      this.setInputsInline(true);
      this.setColour("#C3E516","#C3E516","#a4b835");
      this.setTooltip("Choose an expression");
      this.setHelpUrl("");
    }
  };

   Blocks['clocks'] = {
    init: function() {
      this.appendDummyInput()
          .appendField(new Blockly.FieldDropdown(image_clocks), "image");
      this.setOutput(true, "String");
      this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
      this.setInputsInline(true);
      this.setColour("#C3E516","#C3E516","#a4b835");
      this.setTooltip("Choose a clock face");
      this.setHelpUrl("");
    }
  };

  Blocks['shapes'] = {
      init: function() {
        this.appendDummyInput()
            .appendField(new Blockly.FieldDropdown(image_shapes), "image");
        this.setOutput(true, "String");
        this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
        this.setInputsInline(true);
        this.setColour("#C3E516","#C3E516","#a4b835");
        this.setTooltip("Choose a shape");
        this.setHelpUrl("");
      }
    };

    Blocks['animals'] = {
      init: function() {
        this.appendDummyInput()
            .appendField(new Blockly.FieldDropdown(image_animals), "image");
        this.setOutput(true, "String");
        this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
        this.setInputsInline(true);
        this.setColour("#C3E516","#C3E516","#a4b835");
        this.setTooltip("Choose an animal");
        this.setHelpUrl("");
      }
    };
}